<?php namespace App\Services;

use App\Facades\Infra\HotelGuideManager;
use App\Exceptions\DataBaseException;
class HotelGuideService{

	/**
	 * 新建酒店指南
	 */
	public function createHotelGuide($data){
		if($this->getHotelGuide() != null){
			throw new DataBaseException('已存在数据');
		}
		HotelGuideManager::createHotelGuide($this->formatData($data));

		return;
	}

	/**
	 * 获取酒店指南
	 */

	public function getHotelGuide(){
		return HotelGuideManager::getHotelGuides($this->formatConditions());
	}

	/**
	 * 修改酒店指南
	 *
	 * @param      <type>  $data   The data
	 */
	public function updateHotelGuide($data){
		HotelGuideManager::updateHotelGuide($this->formatConditions(),$data);
	}

	/**
	 * 组成查询条件
	 */
	private function formatConditions(){
		$conditions['hotel_id'] = \Auth::user()->id;

		return $conditions;
	}

	/**
	 * 组测新建数据
	 */
	private function formatData($data){
		$data['hotel_id'] = \Auth::user()->id;

		return $data;
	}
}